<template>
  <div class="common-layout">
    <el-container>
      <el-aside width="200px">
        <img
          src="../../assets/img/1c8b9fa3a7d3883ca06e497c44db364.png"
          alt=""
        />
        <p class="title">家电城后台管理系统</p>
        <el-row class="tac" :unique-opened="true">
          <el-col :span="12">
            <h5 class="mb-2" @click="gotowork">工作台</h5>
            <el-menu
              class="el-menu-vertical-demo"
              @open="handleOpen"
              @close="handleClose"
              :router="true"
              :default-active="route.path"
              :unique-opened="true"
            >
              <el-sub-menu index="1">
                <template #title>
                  <el-icon>
                    <img src="../../assets/img/资产 (1).png" alt="" />
                  </el-icon>
                  <span>财务管理</span>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="/home/modetail">经营明细</el-menu-item>
                  <el-menu-item index="/home/wages">员工薪资</el-menu-item>
                  <el-menu-item index="/home/tools">工具报修</el-menu-item>
                </el-menu-item-group>
                <el-menu-item-group> </el-menu-item-group>
              </el-sub-menu>
              <el-sub-menu index="2">
                <template #title>
                  <el-icon>
                    <img src="../../assets/img/调查.png" alt="" />
                  </el-icon>
                  <span>商品管理</span>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="/home/furniture">家具类</el-menu-item>
                  <el-menu-item index="/home/household">家电类</el-menu-item>
                </el-menu-item-group>
                <el-menu-item-group> </el-menu-item-group>
              </el-sub-menu>
              <el-sub-menu index="3">
                <template #title>
                  <el-icon>
                    <img src="../../assets/img/调查.png" alt="" />
                  </el-icon>
                  <span>订单管理</span>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="/home/orderform">订单管理</el-menu-item>
                </el-menu-item-group>
                <el-menu-item-group> </el-menu-item-group>
              </el-sub-menu>
              <el-sub-menu index="4">
                <template #title>
                  <el-icon>
                    <img src="../../assets/img/调查.png" alt="" />
                  </el-icon>
                  <span>员工管理</span>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="/home/staff">员工管理</el-menu-item>
                </el-menu-item-group>
                <el-menu-item-group> </el-menu-item-group>
              </el-sub-menu>
              <el-sub-menu index="5">
                <template #title>
                  <el-icon>
                    <img src="../../assets/img/wxb工具.png" alt="" />
                  </el-icon>
                  <span>售后维修</span>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="/home/aftersale">售后维修</el-menu-item>
                </el-menu-item-group>
                <el-menu-item-group> </el-menu-item-group>
              </el-sub-menu>
              <el-sub-menu index="6">
                <template #title>
                  <el-icon>
                    <img src="../../assets/img/报销统计.png" alt="" />
                  </el-icon>
                  <span>优惠活动</span>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="/home/discounts">优惠活动</el-menu-item>
                </el-menu-item-group>
                <el-menu-item-group> </el-menu-item-group>
              </el-sub-menu>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <el-container>
        <el-header>
          <div class="work-tap">
            <div class="back" @click="goback">
              <el-icon>
                <Expand />
              </el-icon>
            </div>

            <el-breadcrumb separator="/" :header-cell-style="{ color: '#fff' }">
              <div v-if="urlsObj1">
                <el-breadcrumb-item color="red">{{
                  urlsObj1
                }}</el-breadcrumb-item>
                <el-breadcrumb-item>{{ urlsObj2 }}</el-breadcrumb-item>
                <el-breadcrumb-item v-if="urlsObj3">{{
                  urlsObj3
                }}</el-breadcrumb-item>
              </div>
              <div v-else>
                <el-breadcrumb-item> 工作台 </el-breadcrumb-item>
              </div>
            </el-breadcrumb>
          </div>
          <div class="notice">
            <!-- <el-icon>
              <Bell />
            </el-icon> -->
            <div class="self-pic">
              <img src="../../assets/img/椭圆 1.png" alt="" />
              <ul class="self-information">
                <li @click="login">退出</li>
              </ul>
            </div>
            <el-dropdown @command="handleCommand">
              <span class="el-dropdown-link">
                admin
                <el-icon class="el-icon--right">
                  <arrow-down />
                </el-icon>
              </span>
              <template #dropdown>
                <el-dropdown-menu>
                  <el-dropdown-item command="1">个人中心</el-dropdown-item>
                  <el-dropdown-item command="2">退出登录</el-dropdown-item>
                </el-dropdown-menu>
              </template>
            </el-dropdown>
          </div>
        </el-header>
        <div class="main">
          <RouterView></RouterView>
        </div>
      </el-container>
    </el-container>
  </div>
</template>
<script lang="ts" setup>
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
  Expand,
  Bell,
  ArrowDown,
} from "@element-plus/icons-vue";
import { useRoute, useRouter } from "vue-router";
import { watch, ref, onMounted, computed } from "vue";
import store from "@/store";
import { ElMessage } from "element-plus";
const route = useRoute();
const router = useRouter();
const gotowork = () => {
  router.push("/home/workspace");
};
const handleOpen = (index: string, indexPath: string[]) => {
  console.log(index, indexPath);
};
const handleClose = (key: string, keyPath: string[]) => {
  console.log(key, keyPath);
};
// 登录注册
const login = () => {
  router.push("/login");
};
const handleCommand = (command: string | number | object) => {
  console.log(command);
  if (command === "2") {
    router.push("/login");
    ElMessage({
      message: "退出成功",
      type: "success",
    });
  }
  if (command === "1") {
    router.push("/admin");
  }
};
// 头部目录
let urlsObj1 = ref<any>();
let urlsObj2 = ref<any>();
let urlsObj3 = ref<any>();
let Urls = computed(() => {
  return store.state.routerUrl;
});
watch(Urls, () => {
  console.log(Urls.value);
  // 转中文
  if (Urls.value.split("/")[1] == "home") {
    urlsObj1.value = "工作台";
  }
  if (Urls.value.split("/")[2] == "modetail") {
    urlsObj2.value = "经营明细";
  } else if (Urls.value.split("/")[2] == "wages") {
    urlsObj2.value = "员工薪资";
  } else if (Urls.value.split("/")[2] == "tools") {
    urlsObj2.value = "工具保修";
  } else if (Urls.value.split("/")[2] == "furniture") {
    urlsObj2.value = "家具类";
  } else if (Urls.value.split("/")[2] == "household") {
    urlsObj2.value = "家电类";
  } else if (Urls.value.split("/")[2] == "orderform") {
    urlsObj2.value = "订单管理";
  } else if (Urls.value.split("/")[2] == "aftersale") {
    urlsObj2.value = "售后维修";
  } else if (Urls.value.split("/")[2] == "discounts") {
    urlsObj2.value = "优惠活动";
  }
  if (Urls.value.split("/")[3]) {
    urlsObj3.value = Urls.value.split("/")[3];
  } else {
    urlsObj3.value = "";
  }
});

const goback = () => {
  router.back();
};
</script>

<style lang="less" scoped>
html,
body {
  height: 100%;
}
// 下拉菜单
:deep(.el-dropdown) {
  cursor: pointer;
  color: black;
  display: flex;
  align-items: center;
}
:deep(.el-dropdown-link) {
  display: block;
  display: flex;
  align-items: center;
}
:deep(.el-header .notice .el-icon[data-v-2c5296db]) {
  margin-top: 3px;
}
// wuwuwuwu
.back {
  height: 100%;
  width: 40px;
  font-size: 20px;
  margin-top: -5px;
}
.el-aside {
  position: fixed;
  background-color: #72a7c9;
  height: 100%;
  border-right: 1px solid #000000;
  box-sizing: border-box;

  img {
    width: 199px;
    height: 80px;
  }

  .title {
    width: 199px;
    height: 16px;
    font-size: 16px;
    font-family: Adobe Heiti Std;
    font-weight: bolder;
    color: #030303;
    text-align: center;
  }

  .el-row {
    display: flex;
    flex-direction: column;
    width: 100%;

    .mb-2 {
      width: 199px;
      height: 52px;
      margin-top: 16px;
      text-indent: 50px;
      line-height: 52px;
      font-size: 16px;
      font-family: Adobe Heiti Std;
      font-weight: normal;
      border-top: 1px solid #898989;
      border-bottom: 1px solid #898989;
      background: url(../../assets/img/运营工作台.png) no-repeat 20px 17px
        #72a7c9;
      cursor: pointer;
      transition: 0.3s;
    }

    .mb-2:hover {
      background-color: #ecf5ff;
    }

    .mb-2:active {
      background-color: #6391ad;
    }

    .el-sub-menu {
      width: 199px;
      background-color: #72a7c9;
      border-bottom: 1px solid #898989;

      img {
        width: 20px;
        height: 20px;
      }

      span {
        font-size: 16px;
        font-family: Adobe Heiti Std;
        font-weight: normal;
        color: #030303;
      }
    }
  }
}
::-webkit-scrollbar {
  display: none;
}
.el-header {
  background-color: #72a7c9;
  height: 40px;
  position: fixed;
  width: calc(100% - 200px);
  left: 200px;
  z-index: 99;
  display: flex;
  justify-content: space-between;
  .work-tap {
    display: flex;
    align-items: center;

    :deep(.el-breadcrumb__inner) {
      color: black;
    }

    .el-icon {
      font-size: 24px;
      margin-top: 14px;
      cursor: pointer;
    }

    p {
      width: 80px;
      height: 40px;
      background: #ffffff;
      border-radius: 10px;
      font-size: 16px;
      font-family: Adobe Heiti Std;
      font-weight: normal;
      color: #92d3fc;
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 10px 0px 0px 5px;
    }
  }

  .notice {
    display: flex;

    .el-icon {
      font-size: 20px;
      margin-top: 16px;
      margin-right: 5px;
      cursor: pointer;
    }

    .self-pic {
      width: 30px;
      height: 30px;
      margin-top: 8px;
      border-radius: 50%;
      overflow: hidden;
      display: flex;
      justify-content: center;
      align-items: center;
      cursor: pointer;

      .self-information {
        width: 50px;
        height: 40px;
        background-color: #72a7c9;
        position: absolute;
        right: 10px;
        top: 37px;
        display: none;

        li {
          text-align: center;
          line-height: 40px;
          font-size: 12px;
          color: #ffffff;
          cursor: pointer;
        }
      }
    }

    // .self-pic:hover .self-information {
    //   display: block;
    // }
  }
}

.main {
  position: absolute;
  width: calc(100% - 200px);
  background-color: #ffffff;
  top: 40px;
  left: 200px;

  .box {
    display: flex;
    flex-direction: column;

    .sale {
      display: flex;
      flex: 1;

      .sale-number {
        height: 160px;
        flex: 1;
        // border: 1px solid #030303;
        margin-right: 10px;
        display: flex;
        background-color: #b4dbe7;

        .money {
          height: 160px;
          flex: 1.5;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;

          p:nth-child(1) {
            font-size: 12px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #000000;
          }

          p:nth-child(2) {
            font-size: 30px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #f65e5e;
            margin: 20px 0px 20px 0px;
          }

          p:nth-child(3) {
            font-size: 12px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #000000;
            text-indent: -50px;
          }
        }

        .separate {
          width: 2px;
          height: 30px;
          background-color: #464646;
          margin-top: 65px;
        }

        .number {
          height: 160px;
          flex: 1;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;

          p:nth-child(1) {
            font-size: 12px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #000000;
          }

          p:nth-child(2) {
            font-size: 30px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #fb0000;
            margin: 20px 0px 20px 0px;
          }

          p:nth-child(3) {
            font-size: 12px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #000000;
          }
        }
      }

      .sale-after {
        height: 160px;
        flex: 2;
        // border: 1px solid #030303;
        display: flex;
        background-color: #b4dbe7;

        div {
          height: 160px;
          flex: 1;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;

          p:nth-child(1) {
            font-size: 12px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #030303;
          }

          p:nth-child(2) {
            font-size: 30px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #030303;
            margin: 20px 0px 20px 0px;
          }

          p:nth-child(3) {
            font-size: 12px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #030303;
          }
        }

        .separate {
          display: block;
          width: 2px;
          height: 30px;
          background-color: #464646;
          margin-top: 65px;
        }
      }
    }

    .chart-information {
      display: flex;
      margin-top: 16px;
      flex: 3;

      #chart {
        height: 400px;
        width: 739px;
        flex: 2;
        // border: 1px solid #030303;
        background-color: #b4dbe7;
      }

      .information {
        // height: 400px;
        flex: 1;
        // border: 1px solid #030303;
        margin-left: 17px;
        background-color: #b4dbe7;

        h1 {
          font-size: 18px;
          margin: 10px 0px 0px 15px;
        }

        ul {
          display: flex;
          flex-direction: column;
          align-items: center;
          margin-top: 10px;

          li {
            width: 270px;
            height: 40px;
            // border: 1px solid #030303;
            margin-top: 5px;
            border-radius: 5px;
            background-color: #92d3fc;
            text-indent: 10px;
            line-height: 40px;
            font-size: 14px;
            font-family: Adobe Heiti Std;
            font-weight: normal;
            color: #060606;
            cursor: pointer;
            position: relative;

            .point {
              width: 10px;
              height: 10px;
              border-radius: 50%;
              background-color: #03c2fc;
              position: absolute;
              top: 15px;
              left: -20px;
            }
          }
        }
      }
    }
  }
}
</style>
